//
//  ZBBRecomendCell.m
//  沙哈拉FM
//
//  Created by dllo on 15/11/6.
//  Copyright © 2015年 S1mpl3. All rights reserved.
//

#import "ZBBRecomendCell.h"
#import "FitHeader.h"
#import "UIImageView+WebCache.h"
#import "NSString+CatOut.h"
@implementation ZBBRecomendCell

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self createView];
    }
    return self;
}


- (void)createView{
    
    
    _coverPathImageView = [[UIImageView alloc]init];
    [self addSubview:_coverPathImageView];
    
    _titleTopLabel = [[BaseLabel alloc]init];
    [_titleTopLabel setFontSize:18];
    [self.contentView addSubview:_titleTopLabel];
    
    _titleCenterLabel = [[BaseLabel alloc]init];
    [_titleCenterLabel setFontSize:15];
    _titleCenterLabel.textColor = [UIColor grayColor];
    [self.contentView addSubview:_titleCenterLabel];
    
    _playImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:_playImageView];
    
    _fluxImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:_fluxImageView];
    
    _moreImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:_moreImageView];
    _titleBottomLeftLabel = [[BaseLabel alloc]init];
    [_titleBottomLeftLabel setFontSize:13];
    _titleBottomLeftLabel.textColor = [UIColor grayColor];
    [self.contentView addSubview:_titleBottomLeftLabel];
    _titleBottomRightLabel = [[BaseLabel alloc]init];
    [_titleBottomRightLabel setFontSize:13];
    _titleBottomRightLabel.textColor = [UIColor grayColor];
    [self.contentView addSubview:_titleBottomRightLabel];
    
    
}
- (void)layoutSubviews{
    [super layoutSubviews];
    
    _coverPathImageView.frame = CGRectMake(10 * FITWidth, 10 * FITHeight, 80 * FITWidth, 80 * FITHeight);
    _titleTopLabel.frame = CGRectMake(_coverPathImageView.frame.origin.x + _coverPathImageView.frame.size.width + 10 * FITWidth, _coverPathImageView.frame.origin.y, self.contentView.frame.size.width - _coverPathImageView.frame.size.width - 52 * FITWidth, 20 * FITHeight);
    _titleCenterLabel.frame = CGRectMake(_titleTopLabel.frame.origin.x, _titleTopLabel.frame.origin.y + _titleTopLabel.frame.size.height + 10, _titleTopLabel.frame.size.width, 20 * FITHeight);
    _moreImageView.frame = CGRectMake(_titleCenterLabel.frame.origin.x + _titleCenterLabel.frame.size.width, 40 * FITHeight, 22 * FITHeight, 22 * FITHeight);
    _moreImageView.image = [UIImage imageNamed:@"S1mpl3更多"];
    _titleBottomLeftLabel.frame = CGRectMake(_titleCenterLabel.frame.origin.x + 8 * FITWidth, _titleCenterLabel.frame.origin.y + _titleCenterLabel.frame.size.height + 10, 70 * FITWidth, 20 * FITHeight);
    
    _titleBottomRightLabel.frame = CGRectMake(_titleBottomLeftLabel.frame.origin.x + 8 * FITWidth + _titleBottomLeftLabel.frame.size.width, _titleBottomLeftLabel.frame.origin.y, 70 * FITWidth, 20 * FITHeight);
    
    _playImageView.frame = CGRectMake(_titleTopLabel.frame.origin.x, _titleBottomLeftLabel.frame.origin.y + 6 * FITHeight, 8 * FITWidth, 8 * FITHeight);
    _playImageView.image = [UIImage imageNamed:@"S1mpl3播放"];
    
    _fluxImageView.frame = CGRectMake(_titleBottomLeftLabel.frame.origin.x+ _titleBottomLeftLabel.frame.size.width, _playImageView.frame.origin.y, 8 * FITWidth, 8 * FITHeight);
    _fluxImageView.image = [UIImage imageNamed:@"iconfont-jishu"];
    
}
-(void)setModel:(S1mpl3MoreRecommend *)model
{
    [_coverPathImageView sd_setImageWithURL:[NSURL URLWithString:model.albumCoverUrl290]];
    
    _titleTopLabel.text = model.title;
    _titleCenterLabel.text = model.intro;
    NSString *str = [NSString stringWithFormat:@"%@", model.playsCounts];
    if ([str isEqualToString:@"0"]) {
        _playImageView.image = [UIImage imageNamed:@"iconfont-jishu"];
        
        _titleBottomLeftLabel.text = [NSString stringWithFormat:@"%@集",model.tracks];
        _fluxImageView.hidden = YES;
        _titleBottomRightLabel.hidden = YES;
    }
    else
    {
        _titleBottomLeftLabel.text =  [NSString getStringOfWorth:model.playsCounts];
        _titleBottomRightLabel.text = [NSString stringWithFormat:@"%@集",model.tracks];
        _playImageView.image = [UIImage imageNamed:@"S1mpl3播放"];
        _fluxImageView.hidden = NO;
        _titleBottomRightLabel.hidden = NO;
    }
    
    
    
    
    
}
/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

@end
